<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>Google身份验证器</title>

    <link rel="stylesheet" type="text/css" th:href="@{/js/layui/css/layui.css/}" media="all">
    <link rel="stylesheet" type="text/css" th:href="@{/css/fyn/style.css/}" media="all">
    <script type="text/javascript">
        const randomSecretKey = '[[${randomSecretKey}]]';
        const qrCodeImageBase64 = '[[${qrCodeImageBase64}]]';
    </script>
</head>
<body>

<div>
    <div class="layui-col-md12">
        <div style="text-align: center;">
            <div class="layui-card-header">
                <p id="msgTipsId" style="color: red;font-size: 20px;">该二维码已绑定，如需要请联系管理员！</p>
            </div>
            <div class="layui-card-body">
                <img id="qrCodeImageId" src=""/>
                <!--<img id="qrCodeImageId" src="" style="width: 335px;height: 335px;"/>-->
            </div>
            <!--<button type="button" class="layui-btn layui-btn-danger" onclick="resetCode();">重 置</button>-->
        </div>
    </div>
</div>

<script th:src="@{/js/layui/layui.all.js}"></script>
<script type="text/javascript" th:inline="javascript">
    var $;
    layui.use(['form'], function () {
        // 操作对象
        $ = layui.jquery;

        $.ajax({
            type: "post",
            url: [[${basePath}]] + "/verify/verifyGoogleQRCode",
            success: function (res) {
                if (res.success) {
                    $("#qrCodeImageId").attr('src', res.data);
                    $("#msgTipsId").text("刷新页面后该二维码将失效，请尽快绑定！");
                    return
                }
            }
        });

    });
    // 重置生成二维码
    function resetCode() {
        $.ajax({
            type: "get",
            url: [[${basePath}]] + "/verify/resetGoogleQRCode",
            success: function (res) {
                if (res.success) {
                    $("#qrCodeImageId").attr('src', res.data);
                    $("#msgTipsId").text("刷新页面后该二维码将失效，请尽快绑定！");
                    layer.msg("重置成功，请尽快绑定！", {icon: 1});
                    return
                }
            }
        });
    }
</script>
</body>
</html>